package com.junlaninfo.Manage;

import com.junlaninfo.entity.UserEntity;
import com.junlaninfo.service.LoginService3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

/**
 * Created by 辉 on 2020/7/24.
 */
@Component
public class LoginManag {
    private static final Logger log = LoggerFactory.getLogger(LoginService3.class);

    @Async
    public void asynLogin(UserEntity userEntity) {
        loginLog(userEntity);
        sendSms(userEntity);
        sendEmail(userEntity);
    }

    private void loginLog(UserEntity userEntity) {
        log.info(">>>2.异步开始写登陆的日志<<<");
        try {
            Thread.sleep(2000);
        } catch (Exception e) {

        }
//        int i = 1 / 0;
    }

    private void sendSms(UserEntity userEntity) {
        log.info(">>>3.异步开始发送短信<<<");
        try {
            Thread.sleep(2000);
        } catch (Exception e) {

        }
    }

    private void sendEmail(UserEntity userEntity) {
        log.info(">>>4.异步开始发送邮件<<<");
        try {
            Thread.sleep(2000);
        } catch (Exception e) {

        }
    }
}
